import requests


class DEPApi:
    @classmethod
    def ihrm_dep_add(cls, token, add_body):
        # 部门添加
        add_url = "http://ihrm-test.itheima.net/api/company/department"
        add_heard = {"Content-Type": "application/json", "Authorization": token}
        add_reques = requests.post(url=add_url, headers=add_heard, json=add_body)
        add_re = add_reques.json().get("data").get("id")
        return add_re

    @classmethod
    def ihrm_dep_revise(cls, token, add_id, revise_body):
        # 部门修改
        revise_url = "http://ihrm-test.itheima.net/api/company/department/" + add_id
        revise_heard = {"Content-Type": "application/json", "Authorization": token}
        revise_reques = requests.put(url=revise_url, headers=revise_heard, json=revise_body)
        return revise_reques

    @classmethod
    def ihrm_dep_examine(cls, token, add_id):
        # 部门查询
        examine_url = "http://ihrm-test.itheima.net/api/company/department/" + add_id
        examine_heard = {"Authorization": token}
        examine_reques = requests.get(url=examine_url, headers=examine_heard)
        return examine_reques

    @classmethod
    def ihrm_dep_del(cls, add_id, token):
        # 部门删除
        del_url = "http://ihrm-test.itheima.net/api/company/department/" + add_id
        del_heard = {"Authorization": token}
        del_reques = requests.delete(url=del_url, headers=del_heard)
        return del_reques


